import { tasksGetSum } from "$api/tasks";
import { arrJoin } from "$utils/splitObj";

export default {
  data() {
    return {
      selectIndex: 0,
      myChart: null,
      moduleParam: {
        height: "100vw",
        width: "100vh",
        id: ""
      }
    }
  },
  computed: {
    useOptions() {
      return this.selectIndex === 0 ? this.barChartsOption : this.lineOptions
    },
  },
  methods: {

    async init(index) {
      this.selectIndex = index
      const data = await tasksGetSum({ dateScope: arrJoin(this.dateScope) })
      if (index === 0) {
        this.moduleParam.id = "e1"
        this.initBarChart(data)
      } else {
        this.moduleParam.id = "e2"

        this.initLineChart(data)
      }
    }
  }
}
